package com.leetcode.LC_MED;

import java.util.Arrays;
import java.util.HashMap;

public class LC59 {
    private int[][] generateMatrix(int n) {
        if (n==0){
            return new int[][]{};
        }
        int[][] res = new int[n][n];
        int num = 1;
        int left = 0, right = n-1, top = 0, bottom = n-1;
        while (left<=right && top<=bottom){
            for (int i = left; i <= right; i++) {
                res[top][i] = num++;
            }
            for (int i = top+1; i <= bottom; i++) {
                res[i][right] = num++;
            }
            if (left<right && top<bottom){
                for (int i = right - 1; i > left; i--) {
                    res[bottom][i] = num++;
                }
                for (int i = bottom; i > top; i--) {
                    res[i][left] = num++;
                }
            }
            top++;
            left++;
            bottom--;
            right--;
        }
        return res;
    }

    public static void main(String[] args) {
        LC59 lc59 = new LC59();
        int[][] ints = lc59.generateMatrix(10);
        for (int[] anInt : ints) {
            for (int i : anInt) {
                System.out.print(i+" ");
            }
            System.out.println();
        }
        System.out.println(String.join(",", Arrays.asList("1","2")));
        HashMap<String, String> stringStringHashMap = new HashMap<>();
        stringStringHashMap.put("1","one");
        System.out.println(stringStringHashMap.get("2"));
    }
}
